/*package com.tqz.web.flux.demo.servlet;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.AsyncContext;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

*//**
 * <p>异步的servlet，servlet从3.0开始支持异步，
 * 设置参数 {@link WebServlet#asyncSupported()} 为 <code>true</code> 表示支持异步。
 *
 * @author tianqingzhao
 * @since 2023/3/4 17:44
 *//*
@WebServlet(value = "/async", asyncSupported = true)
public class AsyncServlet extends HttpServlet {

    private static final Logger log = LoggerFactory.getLogger(AsyncServlet.class);

    *//**
     * 最大线程数设置为1，队列容量设置为1，也就是最大能处理两个并发
     *//*
    ThreadPoolExecutor executor = new ThreadPoolExecutor(1, 1, 60,
            TimeUnit.SECONDS, new LinkedBlockingDeque<>(1), (ThreadFactory) Thread::new,
            new AsyncRejectedExecutionHandler());

    @Override
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        log.info("当前线程：{}，请求参数信息：{}", Thread.currentThread().getName(), req.getQueryString());

        // 获取当前请求的上下文，因为异步的，所以要保存一下，否则没有请求上下文，无法响应给客户端。
        AsyncContext asyncContext = req.startAsync();

        AsyncWrapper asyncWrapper = new AsyncWrapper(asyncContext, resp, Thread.currentThread());

        executor.execute(asyncWrapper);
    }

}*/
